
local io = require 'io'
local string = require 'string'
local tostring
    = tostring


module (...)


function alert(msg, title)
  if title then
    io.write('\n=====\n', tostring(title), '\n=====\n')
  end
  io.write(tostring(msg), '\n')
  io.read(1)
end

function confirm(msg, title, default)
  if title then
    io.write('\n=====\n', tostring(title), '\n=====\n')
  end
  io.write(tostring(msg), ' (Y/N)\n>>> ')
  while true do
    local response = string.lower(io.read('*l') or '')
    if (response == 'y') or (response == 'yes') then
      return true
    elseif (response == 'n') or (response == 'no') then
      return false
    end
    io.write('Please enter either Y or N.\n>>> ')
  end
end

function choosefile(def)
  io.write('\nPlease enter the full file path, or just hit enter to cancel:\n>>> ')
  local response = io.read('*l') or ''
  if (response == '') then
    return nil
  end
  return response
end
